package convert;

import com.alibaba.fastjson.JSONObject;
import exception.PackConvertException;

/**
 * Description:  夹逼协议
 * Created by cjq on 2018/1/22
 */
public class ClampPackage implements Transferable {

    private int version;

    private int action;

    private long size;

    private JSONObject body;

    public int getVersion() {
        return version;
    }

    public void setVersion(int version) {
        this.version = version;
    }

    public int getAction() {
        return action;
    }

    public void setAction(int action) {
        this.action = action;
    }

    public long getSize() {
        return size;
    }

    public void setSize(long size) {
        this.size = size;
    }

    public JSONObject getBody() {
        return body;
    }

    public void setBody(JSONObject body) {
        this.body = body;
    }

    public <T> T cast(Class<T> clzz) throws PackConvertException {
        if(clzz.equals(this.getClass())){
            return (T) this;
        }else
            throw new PackConvertException("类型转换错误");

    }
}
